﻿namespace DataAccessTest
{
    using System;

    using DataAccess;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>
    /// This is a test class for MapScaleTest and is intended
    /// to contain all MapScaleTest Unit Tests
    /// </summary>
    [TestClass]
    public class MapScaleTest
    {
        /// <summary>
        /// DataAccess instance used for testing
        /// </summary>
        private static readonly OrienteeringMapsDataAccess OrienteeringMapsDataAccess = new OrienteeringMapsDataAccess();

        /// <summary>
        /// Gets or sets the test context which provides
        /// information about and functionality for the current test run.
        /// </summary>
        private TestContext TestContext
        {
            get; // ReSharper disable UnusedAutoPropertyAccessor.Local
            set; // ReSharper restore UnusedAutoPropertyAccessor.Local
        }

        /// <summary>
        /// Test for successful creation of Scale entries in the database
        /// </summary>
        [DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\Scales.xml", "Scale", DataAccessMethod.Sequential)]
        [DeploymentItem("DataAccessTest\\TestData\\Scales.xml")]
        [TestMethod]
        public void TestScaleCreation()
        {
            OrienteeringMapsDataAccess.AddScale(new MapScale { Scale = int.Parse((string)TestContext.DataRow["ScaleNumber"]), ScaleText = (string)TestContext.DataRow["ScaleText"], ID = Guid.NewGuid() });
            Assert.AreEqual(int.Parse((string)TestContext.DataRow["ExpectedNumerOfScalesInDB"]), OrienteeringMapsDataAccess.GetScales().Count);
        }
    }
}
